﻿@using System.Web.Optimization
@using BlogEngine.Core
@{
    Layout = "~/admin/themes/standard/layout.cshtml";
    if (!Security.IsAuthorizedTo(Rights.EditOwnPosts))
    {
        Security.RedirectForUnauthorizedRequest();
    }
}
<div class="content" ng-controller="PageEditorController">
    <button tabindex="-1" class="sidebar-toggle"><span></span><span></span><span></span></button>
    <div class="content-pages-new-view">
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">Other Features</h4>
                    </div>
                    <div class="modal-body modal-roles">
                        <div class="form-group">
                            <label><input type="checkbox" data-ng-model="lookups.PageOptions.ShowSlug" ng-true-value="true" ng-false-value="false" /> Slug Field</label>
                        </div>
                        <div class="form-group">
                            <label><input type="checkbox" data-ng-model="lookups.PageOptions.ShowDescription" ng-true-value="true" ng-false-value="false" /> Description Field</label>
                        </div>
                        <div class="form-group">
                            <label><input type="checkbox" data-ng-model="lookups.PageOptions.ShowCustomFields" ng-true-value="true" ng-false-value="false" /> Custom Field <a href="http://www.dnbe.net/docs/post/custom-fields" target="_blank">(Learn more)</a></label>
                        </div>
                        <div class="modal-buttons">
                            <button type="button" data-ng-click="saveEditOptions()" class="btn btn-success">{{lbl.save}}</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="focusInput=false">{{lbl.cancel}}</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="modal-custom-fields" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="focusInput=false"><i class="fa fa-times"></i></button>
                        <h4 class="modal-title">{{lbl.add}} {{lbl.customFields}}</h4>
                    </div>
                    <div class="modal-body modal-roles">
                        <div class="form-group">
                            <label class="control-label" for="txtKey">Key</label>
                            <input type="text" id="txtKey" name="txtKey" class="form-control" data-ng-model="editItem.Key" focus-me="focusInput" />
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="txtValue">Value</label>
                            <input type="text" id="txtValue" name="txtValue" class="form-control" data-ng-model="editItem.Value" />
                        </div>
                        <div class="modal-buttons">
                            <button type="button" data-ng-click="addCustom()" class="btn btn-success">{{lbl.add}}</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="focusInput=false">{{lbl.cancel}}</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @* please do not remove this main-header we used it in mobile size. *@
        <div class="main-header clearfix">
            <span ng-if="page.Id"><a href="{{page.RelativeLink}}" class="btn btn-success btn-sm btn-hasicon pull-left" target="_blank"><i class="fa fa-eye"></i> {{lbl.goToPage}}</a></span>
            <span ng-if="page.Id && page.IsPublished"><a href="#" class="btn btn-sm btn-warning btn-hasicon pull-left" ng-click="publish(false)"><i class="fa fa-undo"></i> {{lbl.unpublish}}</a></span>
            <a ng-if="status() < 2" href="#" data-ng-click="publish(true)" class="btn btn-sm btn-success btn-hasicon pull-left"><i class="fa fa-check"></i>{{lbl.publish}}</a>
            <a ng-if="status() == 2" href="#" data-ng-click="save()" class="btn btn-primary btn-sm btn-hasicon pull-left"><i class="fa fa-save"></i>{{lbl.save}}</a>
            <span ng-if="status() < 2"><a href="#" ng-click="save()" class="btn btn-sm btn-primary btn-hasicon pull-left"><i class="fa fa-save"></i> {{lbl.save}}</a></span>
            <a href="" onclick="window.history.back()" class="btn btn-default btn-sm btn-hasicon pull-left"><i class="fa fa-ban"></i>{{lbl.cancel}}</a>
            <span id="spinner" class="loaded pull-left"><i class='fa fa-spinner fa-spin fa-large'></i></span>
        </div>
        <div class="content-inner">
            <form id="form" action="">
                <div class="newpage-wrapper">
                    <div class="newpage-content">
                        <div class="newpage-title"><input type="text" id="txtTitle" name="txtTitle" autocomplete="off" placeholder="{{lbl.titleOfPage}}..." class="form-control" data-ng-model="page.Title" /></div>
                        <div class="editor-wrapper">@RenderPage(BlogConfig.DefaultEditor)</div>
                        <div class="newpage-widget" data-ng-show="lookups.PageOptions.ShowSlug">
                            <label class="newpage-widget-title">{{lbl.slug}}</label>
                            <input type="text" class="form-control form-control-sm" id="txtSlug" data-ng-model="page.Slug" />
                        </div>
                        <div class="newpage-widget" data-ng-show="lookups.PageOptions.ShowDescription">
                            <label class="newpage-widget-title" for="txtExcerpt">{{lbl.description}}</label>
                            <textarea class="form-control form-control-sm" rows="4" id="txtExcerpt" data-ng-model="page.Description"> </textarea>
                        </div>
                    </div>
                    <div class="newpage-sidebar">
                        <div class="newpage-sidebar-content">
                            <div class="newpage-sidebar-buttons">
                                <span ng-if="page.Id"><a href="{{page.RelativeLink}}" class="btn btn-sm btn-block btn-success" target="_blank">{{lbl.goToPage}}</a></span>
                                <span ng-if="page.Id && page.IsPublished"><a href="#" class="btn btn-sm btn-block btn-warning" ng-click="publish(false)">{{lbl.unpublish}}</a></span>
                                <a ng-if="status() < 2" href="#" data-ng-click="publish(true)" class="btn btn-sm btn-block btn-success">{{lbl.publish}}</a>
                                <a ng-if="status() == 2" href="#" data-ng-click="save()" class="btn btn-sm btn-block btn-primary">{{lbl.save}}</a>
                                <span ng-if="status() < 2"><a href="#" ng-click="save()" class="btn btn-sm btn-block btn-primary">{{lbl.save}}</a></span>
                                <a href="" onclick="window.history.back()" class="btn btn-block btn-sm btn-default">{{lbl.cancel}}</a>
                                <span id="spinner" class="loaded"><i class='fa fa-spinner fa-spin fa-large'></i></span>
                                <hr />
                            </div>
                            <div class="newpage-widget">
                                <label class="newpage-widget-title" for="txtKeywords">{{lbl.keywords}}</label>
                                <textarea class="form-control" rows="3" id="txtKeywords" data-ng-model="page.Keywords"> </textarea>
                            </div>
                            <div class="newpage-widget">
                                <label class="newpage-widget-title" for="txtDate">{{lbl.datePublished}}</label>
                                <input type="text" class="form-control form-control-sm dateFormatted" id="txtDate" name="txtDate" data-ng-model="page.DateCreated" />
                            </div>
                            <div class="newpage-widget">
                                <label class="newpage-widget-title" for="selParents">{{lbl.parent}}</label>
                                <select id="selParents" class="form-control form-control-sm" data-ng-options="o.OptionName for o in lookups.PageList" data-ng-model="selectedParent"></select>
                            </div>
                            <div class="newpage-widget">
                                <label class="newpage-widget-title" for="txtSortOrder">{{lbl.sortOrder}}</label>
                                <input type="text" class="form-control form-control-sm" id="txtSortOrder" data-ng-model="page.SortOrder" />
                            </div>
                            <div class="newpage-widget">
                                <label><input type="checkbox" data-ng-model="page.IsFrontPage" name="cbFrontPage" /> {{lbl.isFrontPage}}</label>
                            </div>
                            <div class="newpage-widget">
                                <label><input type="checkbox" data-ng-model="page.ShowInList" name="cbShowInList" /> {{lbl.showInList}}</label>
                            </div>
                            <div class="newpage-widget" data-ng-show="lookups.PageOptions.ShowCustomFields">
                                <label class="newpage-widget-title">{{lbl.customFields}}</label>
                                <a class="btn btn-default btn-sm btn-block" id="btnCustomFields" ng-click="showCustom()" data-toggle="modal">{{lbl.add}}</a>
                                <div id="frm-custom-edit" ng-if="customFields && customFields.length > 0">
                                    <div class="newpage-custom-fields" data-ng-repeat="item in customFields">
                                        <div class="field-name text-ellipsis">{{item.Key}}</div>
                                        <input type="text" class="form-control" data-ng-model="item.Value" />
                                        <button class="field-remove" ng-click="deleteCustom(item.Key, item.ObjectId)" title="{{lbl.doDelete}}"><i class="fa fa-times"></i></button>
                                    </div>
                                </div>
                            </div>
                            <hr />
                            <a class="btn btn-sm btn-hasicon btn-block btn-default" data-toggle="modal" data-target="#myModal"><i class="fa fa-sliders"></i> Customize</a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@Scripts.Render("~/scripts/wysiwyg")
@{
    if (BlogConfig.DefaultEditor == "~/admin/editors/tinymce/editor.cshtml")
    {
        <script src="~/admin/editors/tinymce/tinymce.min.js"></script>
        <script src="~/admin/editors/tinymce/editor.js"></script>
    }
}
